import { defineConfig } from "vite";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import react from "@vitejs/plugin-react";
import path from "path";
import { routerPrefix } from './src/utils/common';
export default defineConfig(({ mode }) => {
  return {
    base: routerPrefix(mode),
    plugins: [
      react(),
      createSvgIconsPlugin({
        // Specify the icon folder to be cached
        iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
        // Specify symbolId format
        symbolId: "icon-[dir]-[name]",

        /**
         * custom insert position
         * @default: body-last
         * @kind: 'body-last' | 'body-first'
         */
        inject: "body-last",

        /**
         * custom dom id
         * @default: __svg__icons__dom__
         */
        customDomId: "__jedi__svg__icons__dom__",
      }),
    ],
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "./src"),
      },
    },
    server: {
      proxy: {
        "/api/v1": {
          target: "http://localhost:3010",
          // target: "http://172.21.0.5:3010",
          // target: "http://39.99.237.46/:3010",
          changeOrigin: true,
          rewrite: (path: string) => {
            return path.replace(/^\/api\/v1/, "");
          },
        },
      },
    },
  };
});
